package com.xebest.web.controller.order;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import com.xebest.common.base.controller.BASEMessage;
import com.xebest.common.base.controller.BaseController;
import com.xebest.common.base.controller.BaseResponse;
import com.xebest.common.enums.erp.order.VenOrderExpFlagEnum;
import com.xebest.common.enums.erp.order.VenOrderPayStatusEnum;
import com.xebest.common.enums.erp.order.VenOrderPayTypeEnum;
import com.xebest.common.enums.erp.order.VenOrderStatusEnum;
import com.xebest.common.enums.erp.storehouse.VenStoreTypeEnum;
import com.xebest.common.util.XeBaseUtil;
import com.xebest.constant.XeConstans;
import com.xebest.util.DateUtil;
import com.xebest.util.SysSetBeanUtils;
import com.xebest.util.XeVenExcelUtil;
import com.xebest.util.XeVenExcelUtilMultipleSheet;
import com.xebest.util.msg.XeVenOrderMsg;
import com.xebest.web.controller.export.*;
import com.xebest.web.form.XeVenInquirySheetForm;
import com.xebest.web.form.XeVenOrderForm;
import com.xebest.web.model.XeVenOrderExportTask;
import com.xebest.web.service.ExportTaskService;
import com.xebest.web.service.XeVenOrderCenterExportService;
import com.xebest.web.view.ErpUserInfo;
import org.apache.commons.lang.StringUtils;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;


/**
 * 订单中心导出
 *
 * @author 赵盼飞
 */
@RestController
@RequestMapping("orderCenterExport")
public class XeVenOrderCenterExportController extends BaseController {

    private static final Logger log = LoggerFactory.getLogger(XeVenOrderCenterExportController.class);//日志记录类

    @Autowired
    private XeVenOrderCenterExportService orderCenterExportService;//处理订单中心导出
    @Autowired
    private ExportTaskService exportTaskService;//处理生成定制任务
    @Value("${xeven.erp.exportTempletDir}")
    private String exportTempletDir;//导出文件目录


    /**
     * 待付款订单列表导出
     *
     * @author 赵盼飞
     */
    @RequestMapping("paymentOrderList")
    public @ResponseBody
    BaseResponse exportPaymentOrderList(@ModelAttribute XeVenOrderForm form, HttpServletResponse response) {

        try {
            //测试
            String[] str = new String[]{"orderId", "createDate", "orderStatus", "orderSource", "orderSourceType", "venName", "loginAccount",
                    "caConsignee", "caPhone", "caStoreName", "caArea", "caStreet", "orderRemark", "shipType", "promotOrderType", "salesmanName", "custMagName", "purchaseType", "payType",
                    "payStatus", "totalAmount", "freAmount", "pmtAmount", "payAbleAmount", "platPmtAmount", "cpnsPmtAomount", "specialDisamount"};
            form.setFieldArr(str);
            //1、验证参数
            if (form.getFieldArr().length <= 0) {
                return sendAjaxError(BASEMessage.PARAM_ERROR);
            }
            //设置默认时间
            if (judgeOrderTime(form)) return sendAjaxError(BASEMessage.PARAM_ERROR, XeVenOrderMsg.TIME_MSG);
            setOrderTime(form);
            ErpUserInfo userInfo = SysSetBeanUtils.getErpUserInfo(super.getErpLoginUserInfo());
            form.setUserCode(userInfo.getUserCode());
            //2.获取数据
            form.setPayStatus(VenOrderPayStatusEnum.UNPAID.getValue());
            form.setPayType(VenOrderPayTypeEnum.ONLINE_PAY.getValue());
            form.setZpOrder(XeConstans._XE_ONE);
            form.setOrderStatus(VenOrderStatusEnum.WAIT_DIS.getValue());
            form.setOrderException(VenOrderExpFlagEnum.NO_PROBLEM.getValue());
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("orderForm", form);
            if (XeConstans._XE_TWO == userInfo.getAdminFlag()) {
                if (StringUtils.isNotBlank(userInfo.getRoleIds())) {
                    paramMap.put("roleId", userInfo.getRoleIds().split(","));
                } else {
                    paramMap.put("roleId", null);
                }
                paramMap.put("admin", "noAdmin");
            } else {
                paramMap.put("admin", null);
            }
            List<XeVenOrderExportDTO> orderExportDTOList = orderCenterExportService.queryExportOrderList(paramMap);
//			if (null == orderExportDTOList || orderExportDTOList.size() == 0)
//				return sendAjaxOK("导出数据为空！");
            int size = orderExportDTOList.size();
            for (int i = 0; i < size; i++) {
                XeVenOrderExportDTO orderExportDTO = orderExportDTOList.get(i);
//			orderExportDTOList.stream().forEachOrdered(orderExportDTO -> {
                if (StringUtils.isNotBlank(orderExportDTO.getCaAreaId())) {
                    String orgAreaName = XeBaseUtil.baseUtil.getOrgAreaName(Integer.parseInt(orderExportDTO.getCaAreaId().trim()));
                    orderExportDTO.setCaArea(orgAreaName);
                } else if (StringUtils.isNotBlank(orderExportDTO.getCaCityId()) && StringUtils.isBlank(orderExportDTO.getCaAreaId())) {
                    String caCityName = XeBaseUtil.baseUtil.getAreaName(Integer.parseInt(orderExportDTO.getCaCityId().trim()));
                    String caProvinceName = XeBaseUtil.baseUtil.getAreaName(Integer.parseInt(orderExportDTO.getCaProvinceId().trim()));
                    orderExportDTO.setCaArea(caCityName + "" + caProvinceName);
                }
                if (StringUtils.isNotBlank(orderExportDTO.getSalesmanName())) {
                    orderExportDTO.setSalesmanName(orderExportDTO.getSalesmanName() + orderExportDTO.getSalesmanPhone());
                }
            }
//			});
            //3.判断导数数据是否需要生成定制任务，限制最多导出50000条数据，大于50000生成定制任务
            Integer pageCount = XeVenExcelUtil.getPageCount(orderExportDTOList.size(), 50000);

            if (pageCount <= 1) {
                //4.导出
                boolean rs = XeVenExcelUtil.exportExcelService(orderExportDTOList, new XeVenOrderExportDTO(), form.getFieldArr(), exportTempletDir, "PAYMENTORDERLIST-", response);
                if (rs) {
                    return sendAjaxOK();
                } else {
                    return sendAjaxError();
                }
            } else {
                //5.如果导出数据大于50000，生成定制任务，异步进行导出
                XeVenOrderExportTask orderExportDTOTask = new XeVenOrderExportTask();
                orderExportDTOTask.setEtName("com.xebest.job.common.reflect.ExportOrderList");
                orderExportDTOTask.setEtParam(JSONObject.toJSONString(form));
                orderExportDTOTask.setEtStatus(1);
                orderExportDTOTask.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                orderExportDTOTask.setCreateUser(userInfo.getUserName());
                orderExportDTOTask.setUserCode(userInfo.getUserCode());
                exportTaskService.insertExportTask(orderExportDTOTask);
                Map<String, Object> rsMap = Maps.newHashMap();
                rsMap.put("info", "亲,您导出的数据量过大,为了避免对服务器造成过大压力，您的导出请求已经被系统自动订制！\\n请您到(【系统监控】>【导出Excle信息列表】)查看您的导出进度！给您带来不便，请谅解！");
                return sendAjaxOK(rsMap);
            }
        } catch (Exception e) {
            log.error("待付款订单列表导出接口异常：{}", e);
            return sendAjaxError();
        }
    }


    /**
     * 待付款订单列表导出明细
     *
     * @author 赵盼飞
     */
    @RequestMapping("paymentOrderDetail")
    public @ResponseBody
    BaseResponse exportPaymentOrderDetail(@ModelAttribute XeVenOrderForm form, HttpServletResponse response) {
        try {
            //前端所传
            String[] fieldArr = {"orderId", "createDate", "orderStatus", "orderSource", "venName", "loginAccount", "caConsignee", "caPhone", "caStoreName",
                    "caArea", "caStreet", "orderRemark", "shipType", "salesmanName", "custMagName", "payType", "payStatus",
                    "totalAmount", "proNum", "proName", "proCategoryName", "pricingTypeStr", "proUnit", "specValue",
                    "proPrice", "proCostPrice", "purchaseNum", "normWeight", "realSendNum", "orderAmount", "freAmount", "pmtAmount",
                    "specialDisamount", "platPmtAmount", "venPmtAmount"};
            form.setFieldArr(fieldArr);
            //1、验证参数
            if (form.getFieldArr().length <= 0) {
                return sendAjaxError(BASEMessage.PARAM_ERROR);
            }
            //设置默认时间
            if (judgeOrderTime(form)) return sendAjaxError(BASEMessage.PARAM_ERROR, XeVenOrderMsg.TIME_MSG);
            setOrderTime(form);
            ErpUserInfo userInfo = SysSetBeanUtils.getErpUserInfo(super.getErpLoginUserInfo());
            form.setUserCode(userInfo.getUserCode());
            form.setPayStatus(VenOrderPayStatusEnum.UNPAID.getValue());
            form.setPayType(VenOrderPayTypeEnum.ONLINE_PAY.getValue());
            form.setZpOrder(XeConstans._XE_ONE);
            form.setOrderStatus(VenOrderStatusEnum.WAIT_DIS.getValue());
            form.setOrderException(VenOrderExpFlagEnum.NO_PROBLEM.getValue());
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("orderForm", form);
            if (XeConstans._XE_TWO == userInfo.getAdminFlag()) {
                if (StringUtils.isNotBlank(userInfo.getRoleIds())) {
                    paramMap.put("roleId", userInfo.getRoleIds().split(","));
                } else {
                    paramMap.put("roleId", null);
                }
                paramMap.put("admin", "noAdmin");
            } else {
                paramMap.put("admin", null);
            }
            //2.获取数据
            List<XeVenOrderDetailExportDTO> orderDetailList = orderCenterExportService.queryExportOrderDetailList(paramMap);
//			if (null == orderDetailList || orderDetailList.size() == 0)
//				return sendAjaxOK("导出数据为空！");
            //3.判断导数数据是否需要生成定制任务，限制最多导出50000条数据，大于50000生成定制任务
            Integer pageCount = XeVenExcelUtil.getPageCount(orderDetailList.size(), 50000);
            if (pageCount <= 1) {
                //4.导出
                boolean rs = XeVenExcelUtil.exportExcelService(orderDetailList, new XeVenOrderDetailExportDTO(), form.getFieldArr(), exportTempletDir, "PAYMENTORDERDETAIL-", response);
                if (rs) {
                    return sendAjaxOK();
                } else {
                    return sendAjaxError();
                }
            } else {
                //5.如果导出数据大于50000，生成定制任务，异步进行导出
                XeVenOrderExportTask orderExportDTOTask = new XeVenOrderExportTask();
                orderExportDTOTask.setEtName("com.xebest.job.common.reflect.ExportOrderDetailList");
                orderExportDTOTask.setEtParam(JSONObject.toJSONString(form));
                orderExportDTOTask.setEtStatus(1);
                orderExportDTOTask.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                orderExportDTOTask.setCreateUser(userInfo.getUserName());
                orderExportDTOTask.setUserCode(userInfo.getUserCode());
                exportTaskService.insertExportTask(orderExportDTOTask);
                Map<String, Object> rsMap = Maps.newHashMap();
                rsMap.put("info", "亲,您导出的数据量过大,为了避免对服务器造成过大压力，您的导出请求已经被系统自动订制！\\n请您到(【系统监控】>【导出Excle信息列表】)查看您的导出进度！给您带来不便，请谅解！");
                return sendAjaxOK(rsMap);
            }
        } catch (Exception e) {
            log.error("待付款订单列表导出明细接口异常：{}", e);
            return sendAjaxError();
        }
    }


    /**
     * 订单查询列表导出
     *
     * @author 赵盼飞
     */
    @RequestMapping("orderList")
    public @ResponseBody
    BaseResponse exportOrderList(@ModelAttribute XeVenOrderForm form, HttpServletResponse response) {

        try {
            String[] str = new String[]{
                    "orderId", "createDate", "orderStatus", "orderSource", "orderSourceType", "venName", "printBatch", "loginAccount", "caConsignee", "caPhone", "caStoreName",
                    "caArea", "caStreet", "orderRemark", "shipType", "promotOrderType", "salesmanName", "custMagName", "purchaseType", "storeName", "sendTime",
                    "payNumber", "payType", "payStatus", "payTime", "totalAmount", "freAmount", "pmtAmount",
                    "payAbleAmount", "proPayAmount", "refundAmount", "platPmtAmount", "cpnsPmtAomount", "specialDisamount"
            };
            form.setFieldArr(str);
            //1、验证参数
            if (form.getFieldArr().length <= 0) {
                return sendAjaxError(BASEMessage.PARAM_ERROR);
            }
            if (null == form.getOrderStatus()) {
                if (StringUtils.isBlank(form.getOrderId())) {
                    form.setNoOrderStatus(VenOrderStatusEnum.CANCEL.getValue());
                }
            }
            if (judgeOrderTime(form)) return sendAjaxError(BASEMessage.PARAM_ERROR, XeVenOrderMsg.TIME_MSG);
            setOrderTime(form);
            ErpUserInfo userInfo = SysSetBeanUtils.getErpUserInfo(super.getErpLoginUserInfo());
            form.setUserCode(userInfo.getUserCode());
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("orderForm", form);
            if (XeConstans._XE_TWO == userInfo.getAdminFlag()) {
                if (StringUtils.isNotBlank(userInfo.getRoleIds())) {
                    paramMap.put("roleId", userInfo.getRoleIds().split(","));
                } else {
                    paramMap.put("roleId", null);
                }
                paramMap.put("admin", "noAdmin");
            } else {
                paramMap.put("admin", null);
            }
            List<XeVenOrderExportDTO> orderExportDTOList = orderCenterExportService.queryExportOrderList(paramMap);
//			if (null == orderExportDTOList || orderExportDTOList.size() == 0)
//				return sendAjaxOK("导出数据为空！");
            int size = orderExportDTOList.size();
            for (int i = 0; i < size; i++) {
                XeVenOrderExportDTO orderExportDTO = orderExportDTOList.get(i);
//			orderExportDTOList.stream().forEachOrdered(orderExportDTO -> {
                setCaArea(orderExportDTO);
                if (StringUtils.isNotEmpty(orderExportDTO.getPayType())) {
                    //实收
                    orderExportDTO.setProPayAmount(new BigDecimal("0"));
                    //应收
                    orderExportDTO.setPayAbleAmount(orderExportDTO.getPayAbleAmount());
                    if (orderExportDTO.getConfirmSendNum() == 2) {
                        //应收
                        orderExportDTO.setPayAbleAmount(orderExportDTO.getEpayReceAmt());
                    }
                    if (orderExportDTO.getPayType().equals("货到付款") && orderExportDTO.getOrderStatus().equals("已完成")) {
                        orderExportDTO.setProPayAmount(orderExportDTO.getEpayReceAmt());
                    }
                    if (orderExportDTO.getPayType().equals("在线支付") && orderExportDTO.getPayStatus().equals("已支付")) {
                        orderExportDTO.setProPayAmount(orderExportDTO.getPayAbleAmount());
                    }
                }
                if (StringUtils.isNotBlank(orderExportDTO.getSalesmanName())) {
                    orderExportDTO.setSalesmanName(orderExportDTO.getSalesmanName() + orderExportDTO.getSalesmanPhone());
                }
            }
//			});
            //3.判断导数数据是否需要生成定制任务，限制最多导出50000条数据，大于50000生成定制任务
            Integer pageCount = XeVenExcelUtil.getPageCount(orderExportDTOList.size(), 50000);
            if (pageCount <= 1) {
                //4.导出
                boolean rs = XeVenExcelUtil.exportExcelService(orderExportDTOList, new XeVenOrderExportDTO(), form.getFieldArr(), exportTempletDir, "ORDERLIST-", response);
                if (rs) {
                    return sendAjaxOK();
                } else {
                    return sendAjaxError();
                }
            } else {
                //5.如果导出数据大于50000，生成定制任务，异步进行导出
                XeVenOrderExportTask orderExportDTOTask = new XeVenOrderExportTask();
                orderExportDTOTask.setEtName("com.xebest.job.common.reflect.ExportOrderList");
                orderExportDTOTask.setEtParam(JSONObject.toJSONString(form));
                orderExportDTOTask.setEtStatus(1);
                orderExportDTOTask.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                orderExportDTOTask.setCreateUser(userInfo.getUserName());
                orderExportDTOTask.setUserCode(userInfo.getUserCode());
                exportTaskService.insertExportTask(orderExportDTOTask);
                Map<String, Object> rsMap = Maps.newHashMap();
                rsMap.put("info", "亲,您导出的数据量过大,为了避免对服务器造成过大压力，您的导出请求已经被系统自动订制！\\n请您到(【系统监控】>【导出Excle信息列表】)查看您的导出进度！给您带来不便，请谅解！");
                return sendAjaxOK(rsMap);
            }
        } catch (Exception e) {
            log.error("订单查询列表导出接口异常：{}", e);
            return sendAjaxError();
        }
    }

    private void setCaArea(XeVenOrderExportDTO orderExportDTO) {
        if (StringUtils.isNotBlank(orderExportDTO.getCaAreaId())) {
            String orgAreaName = XeBaseUtil.baseUtil.getOrgAreaName(Integer.parseInt(orderExportDTO.getCaAreaId().trim()));
            orderExportDTO.setCaArea(orgAreaName);
        } else if (StringUtils.isNotBlank(orderExportDTO.getCaCityId()) && StringUtils.isBlank(orderExportDTO.getCaAreaId())) {
            String caCityName = XeBaseUtil.baseUtil.getAreaName(Integer.parseInt(orderExportDTO.getCaCityId().trim()));
            String caProvinceName = XeBaseUtil.baseUtil.getAreaName(Integer.parseInt(orderExportDTO.getCaProvinceId().trim()));
            orderExportDTO.setCaArea(caCityName + "" + caProvinceName);
        }
    }

    /**
     * 订单查询列表导出明细
     *
     * @author 赵盼飞
     */
    @RequestMapping("orderDetail")
    public @ResponseBody
    BaseResponse exportOrderDetail(@ModelAttribute XeVenOrderForm form, HttpServletResponse response) {
        try {
            //测试
            String[] fieldArr = {
                    "orderId", "createDate", "orderStatus", "orderSource", "venName", "printBatch", "loginAccount", "caConsignee", "caPhone", "caStoreName",
                    "caArea", "caStreet", "orderRemark", "shipType", "salesmanName", "custMagName", "storeName", "sendTime",
                    "payNumber", "payType", "payStatus", "payTime", "totalAmount",
                    "proName", "proNum", "proCategoryName",
                    "pricingTypeStr", "proUnit", "specValue", "proPrice", "proCostPrice", "purchaseNum", "normWeight", "orderAmount", "realSendNum",
                    "differenceNum", "differenceAmountDetail", "realSendAmountDetail", "freAmount", "pmtAmount", "specialDisamount",
                    "platPmtAmount", "venPmtAmount"
            };
            form.setFieldArr(fieldArr);
            //1、验证参数
            if (form.getFieldArr().length <= 0) {
                return sendAjaxError(BASEMessage.PARAM_ERROR);
            }
            if (null == form.getOrderStatus()) {
                if (StringUtils.isBlank(form.getOrderId())) {
                    form.setNoOrderStatus(VenOrderStatusEnum.CANCEL.getValue());
                }
            }
            if (judgeOrderTime(form)) return sendAjaxError(BASEMessage.PARAM_ERROR, XeVenOrderMsg.TIME_MSG);
            setOrderTime(form);
            ErpUserInfo userInfo = SysSetBeanUtils.getErpUserInfo(super.getErpLoginUserInfo());
            form.setUserCode(userInfo.getUserCode());
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("orderForm", form);
            if (XeConstans._XE_TWO == userInfo.getAdminFlag()) {
                if (StringUtils.isNotBlank(userInfo.getRoleIds())) {
                    paramMap.put("roleId", userInfo.getRoleIds().split(","));
                } else {
                    paramMap.put("roleId", null);
                }
                paramMap.put("admin", "noAdmin");
            } else {
                paramMap.put("admin", null);
            }
            List<XeVenOrderDetailExportDTO> orderDetailList = orderCenterExportService.queryExportOrderDetailList(paramMap);
//			if (null == orderDetailList || orderDetailList.size() == 0)
//				return sendAjaxOK("导出数据为空！");
            //3.判断导数数据是否需要生成定制任务，限制最多导出50000条数据，大于50000生成定制任务
            Integer pageCount = XeVenExcelUtil.getPageCount(orderDetailList.size(), 50000);
            if (pageCount <= 1) {
                //4.导出
                boolean rs = XeVenExcelUtil.exportExcelService(orderDetailList, new XeVenOrderDetailExportDTO(), form.getFieldArr(), exportTempletDir, "ORDERDETAILLIST-", response);
                if (rs) {
                    return sendAjaxOK();
                } else {
                    return sendAjaxError();
                }
            } else {
                //5.如果导出数据大于50000，生成定制任务，异步进行导出
                XeVenOrderExportTask orderExportDTOTask = new XeVenOrderExportTask();
                orderExportDTOTask.setEtName("com.xebest.job.common.reflect.ExportOrderDetailList");
                orderExportDTOTask.setEtParam(JSONObject.toJSONString(form));
                orderExportDTOTask.setEtStatus(1);
                orderExportDTOTask.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                orderExportDTOTask.setCreateUser(userInfo.getUserName());
                orderExportDTOTask.setUserCode(userInfo.getUserCode());
                exportTaskService.insertExportTask(orderExportDTOTask);
                Map<String, Object> rsMap = Maps.newHashMap();
                rsMap.put("info", "亲,您导出的数据量过大,为了避免对服务器造成过大压力，您的导出请求已经被系统自动订制！\\n请您到(【系统监控】>【导出Excle信息列表】)查看您的导出进度！给您带来不便，请谅解！");
                return sendAjaxOK(rsMap);
            }
        } catch (Exception e) {
            log.error("订单查询列表导出明细接口异常：{}", e);
            return sendAjaxError();
        }
    }


    /**
     * 异常订单处理列表导出
     *
     * @author 赵盼飞
     */
    @RequestMapping("exceptionOrderList")
    public @ResponseBody
    BaseResponse exportExceptionOrderList(@ModelAttribute XeVenOrderForm form, HttpServletResponse response) {

        try {
            String[] str = new String[]{
                    "orderId", "createDate", "orderStatus", "orderSource", "orderSourceType", "venName", "loginAccount", "caConsignee", "caPhone", "caStoreName",
                    "caArea", "caStreet", "orderRemark", "shipType", "promotOrderType", "salesmanName", "custMagName", "purchaseType", "storeName", "sendTime",
                    "payNumber", "payType", "payStatus", "payTime", "totalAmount", "freAmount", "pmtAmount",
                    "payAbleAmount", "proPayAmount", "platPmtAmount", "cpnsPmtAomount", "specialDisamount"
            };
            form.setFieldArr(str);
            //1、验证参数
            if (form.getFieldArr().length <= 0) {
                return sendAjaxError(BASEMessage.PARAM_ERROR);
            }
            //设置时间
            if (judgeOrderTime(form)) return sendAjaxError(BASEMessage.PARAM_ERROR, XeVenOrderMsg.TIME_MSG);
            setOrderTime(form);
            ErpUserInfo userInfo = SysSetBeanUtils.getErpUserInfo(super.getErpLoginUserInfo());
            form.setUserCode(userInfo.getUserCode());

            form.setOrderException(VenOrderExpFlagEnum.PROBLEM.getValue());
            form.setZpOrder(XeConstans._XE_ONE);
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("orderForm", form);
            if (XeConstans._XE_TWO == userInfo.getAdminFlag()) {
                if (StringUtils.isNotBlank(userInfo.getRoleIds())) {
                    paramMap.put("roleId", userInfo.getRoleIds().split(","));
                } else {
                    paramMap.put("roleId", null);
                }
                paramMap.put("admin", "noAdmin");
            } else {
                paramMap.put("admin", null);
            }
            //2.获取数据
            List<XeVenOrderExportDTO> orderExportDTOList = orderCenterExportService.queryExportOrderList(paramMap);
//			if (null == orderExportDTOList || orderExportDTOList.size() == 0)
//				return sendAjaxOK("导出数据为空！");
//			orderExportDTOList.stream().forEachOrdered(orderExportDTO -> {
            int size = orderExportDTOList.size();
            for (int i = 0; i < size; i++) {
                XeVenOrderExportDTO orderExportDTO = orderExportDTOList.get(i);
                if (StringUtils.isNotBlank(orderExportDTO.getCaAreaId())) {
                    String orgAreaName = XeBaseUtil.baseUtil.getOrgAreaName(Integer.parseInt(orderExportDTO.getCaAreaId().trim()));
                    orderExportDTO.setCaArea(orgAreaName);
                } else if (StringUtils.isNotBlank(orderExportDTO.getCaCityId()) && StringUtils.isBlank(orderExportDTO.getCaAreaId())) {
                    String caCityName = XeBaseUtil.baseUtil.getAreaName(Integer.parseInt(orderExportDTO.getCaCityId().trim()));
                    String caProvinceName = XeBaseUtil.baseUtil.getAreaName(Integer.parseInt(orderExportDTO.getCaProvinceId().trim()));
                    orderExportDTO.setCaArea(caCityName + "" + caProvinceName);
                }
                //应收
                orderExportDTO.setPayAbleAmount(orderExportDTO.getPayAbleAmount());
                //实收
                orderExportDTO.setProPayAmount(orderExportDTO.getPayAbleAmount());
                if (orderExportDTO.getPayType().equals("货到付款")) {
                    //实收
                    orderExportDTO.setProPayAmount(new BigDecimal("0"));
                }
                if (StringUtils.isNotBlank(orderExportDTO.getSalesmanName())) {
                    orderExportDTO.setSalesmanName(orderExportDTO.getSalesmanName() + orderExportDTO.getSalesmanPhone());
                }
            }
//			});

//			if(null != orderExportDTOList && orderExportDTOList.size()>0){
            //3.判断导数数据是否需要生成定制任务，限制最多导出50000条数据，大于50000生成定制任务
            Integer pageCount = XeVenExcelUtil.getPageCount(orderExportDTOList.size(), 50000);
            if (pageCount <= 1) {
                //4.导出
                boolean rs = XeVenExcelUtil.exportExcelService(orderExportDTOList, new XeVenOrderExportDTO(), form.getFieldArr(), exportTempletDir, "ORDERLIST-", response);
                if (rs) {
                    return sendAjaxOK();
                } else {
                    return sendAjaxError();
                }
            } else {
                //5.如果导出数据大于50000，生成定制任务，异步进行导出
                XeVenOrderExportTask orderExportDTOTask = new XeVenOrderExportTask();
                orderExportDTOTask.setEtName("com.xebest.job.common.reflect.ExportOrderList");
                orderExportDTOTask.setEtParam(JSONObject.toJSONString(form));
                orderExportDTOTask.setEtStatus(1);
                orderExportDTOTask.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                orderExportDTOTask.setCreateUser(userInfo.getUserName());
                orderExportDTOTask.setUserCode(userInfo.getUserCode());
                exportTaskService.insertExportTask(orderExportDTOTask);
                Map<String, Object> rsMap = Maps.newHashMap();
                rsMap.put("info", "亲,您导出的数据量过大,为了避免对服务器造成过大压力，您的导出请求已经被系统自动订制！\\n请您到(【系统监控】>【导出Excle信息列表】)查看您的导出进度！给您带来不便，请谅解！");
                return sendAjaxOK(rsMap);
            }
//			}else{
//				return sendAjaxOK("导出数据为空！");
//			}
        } catch (Exception e) {
            log.error("异常订单处理列表导出接口异常：{}", e);
            return sendAjaxError();
        }
    }

    /**
     * 异常订单处理列表导出明细
     *
     * @author 赵盼飞
     */
    @RequestMapping("exceptionOrderDetail")
    public @ResponseBody
    BaseResponse exportExceptionOrderDetail(@ModelAttribute XeVenOrderForm form, HttpServletResponse response) {
        try {
            //测试
            String[] fieldArr = {
                    "orderId", "createDate", "orderStatus", "orderSource", "venName", "loginAccount", "caConsignee", "caPhone", "caStoreName",
                    "caArea", "caStreet", "orderRemark", "shipType", "salesmanName", "custMagName", "storeName", "sendTime",
                    "payNumber", "payType", "payStatus", "payTime", "totalAmount", "proNum", "proName", "proCategoryName",
                    "pricingTypeStr", "proUnit", "specValue", "proPrice", "proCostPrice", "purchaseNum", "normWeight", "realSendNum",
                    "differenceNum", "differenceAmountDetail", "orderAmount", "freAmount", "pmtAmount", "specialDisamount",
                    "platPmtAmount", "venPmtAmount"
            };
            form.setFieldArr(fieldArr);
            //1、验证参数
            if (form.getFieldArr().length <= 0) {
                return sendAjaxError(BASEMessage.PARAM_ERROR);
            }
            //设置时间
            if (judgeOrderTime(form)) return sendAjaxError(BASEMessage.PARAM_ERROR, XeVenOrderMsg.TIME_MSG);
            setOrderTime(form);
            ErpUserInfo userInfo = SysSetBeanUtils.getErpUserInfo(super.getErpLoginUserInfo());
            form.setUserCode(userInfo.getUserCode());
            form.setOrderException(VenOrderExpFlagEnum.PROBLEM.getValue());
            form.setZpOrder(XeConstans._XE_ONE);
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("orderForm", form);
            if (XeConstans._XE_TWO == userInfo.getAdminFlag()) {
                if (StringUtils.isNotBlank(userInfo.getRoleIds())) {
                    paramMap.put("roleId", userInfo.getRoleIds().split(","));
                } else {
                    paramMap.put("roleId", null);
                }
                paramMap.put("admin", "noAdmin");
            } else {
                paramMap.put("admin", null);
            }
            //2.获取数据
            List<XeVenOrderDetailExportDTO> orderDetailList = orderCenterExportService.queryExportOrderDetailList(paramMap);
//			if (null == orderDetailList || orderDetailList.size() == 0)
//				return sendAjaxOK("导出数据为空！");
//			if(null != orderDetailList && orderDetailList.size()>0){
            //3.判断导数数据是否需要生成定制任务，限制最多导出50000条数据，大于50000生成定制任务
            Integer pageCount = XeVenExcelUtil.getPageCount(orderDetailList.size(), 50000);
            if (pageCount <= 1) {
                //4.导出
                boolean rs = XeVenExcelUtil.exportExcelService(orderDetailList, new XeVenOrderDetailExportDTO(), form.getFieldArr(), exportTempletDir, "ORDERDETAILLIST-", response);
                if (rs) {
                    return sendAjaxOK();
                } else {
                    return sendAjaxError();
                }
            } else {
                //5.如果导出数据大于50000，生成定制任务，异步进行导出
                XeVenOrderExportTask orderExportDTOTask = new XeVenOrderExportTask();
                orderExportDTOTask.setEtName("com.xebest.job.common.reflect.ExportOrderDetailList");
                orderExportDTOTask.setEtParam(JSONObject.toJSONString(form));
                orderExportDTOTask.setEtStatus(1);
                orderExportDTOTask.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                orderExportDTOTask.setCreateUser(userInfo.getUserName());
                orderExportDTOTask.setUserCode(userInfo.getUserCode());
                exportTaskService.insertExportTask(orderExportDTOTask);
                Map<String, Object> rsMap = Maps.newHashMap();
                rsMap.put("info", "亲,您导出的数据量过大,为了避免对服务器造成过大压力，您的导出请求已经被系统自动订制！\\n请您到(【系统监控】>【导出Excle信息列表】)查看您的导出进度！给您带来不便，请谅解！");
                return sendAjaxOK(rsMap);
            }
//			}else{
//				return sendAjaxOK("导出数据为空！");
//			}
        } catch (Exception e) {
            log.error("异常订单处理列表导出明细接口异常：{}", e);
            return sendAjaxError();
        }
    }


    /**
     * 订单处理列表导出
     *
     * @author 赵盼飞
     */
    @RequestMapping("exportHandleOrderList")
    public @ResponseBody
    BaseResponse exportHandleOrderList(@ModelAttribute XeVenOrderForm form, HttpServletResponse response) {

        try {
            log.info("订单处理列表---->" + JSON.toJSONString(form));
            String[] str = new String[]{
                    "orderId", "createDate", "orderStatus", "orderSource", "orderSourceType", "venName", "loginAccount", "caConsignee", "caPhone", "caStoreName",
                    "caArea", "caStreet", "orderRemark", "shipType", "promotOrderType", "salesmanName", "custMagName", "purchaseType", "storeName", "sendTime",
                    "payNumber", "payType", "payStatus", "payTime", "totalAmount", "freAmount", "pmtAmount",
                    "payAbleAmount", "proPayAmount", "platPmtAmount", "cpnsPmtAomount", "specialDisamount"
            };
            form.setFieldArr(str);
            //1、验证参数
            if (form.getFieldArr().length <= 0) {
                return sendAjaxError(BASEMessage.PARAM_ERROR);
            }
            //设置时间
            if (judgeOrderTime(form)) return sendAjaxError(BASEMessage.PARAM_ERROR, XeVenOrderMsg.TIME_MSG);
            setOrderTime(form);
            ErpUserInfo userInfo = SysSetBeanUtils.getErpUserInfo(super.getErpLoginUserInfo());
            form.setUserCode(userInfo.getUserCode());
            form.setOrderStatus(VenOrderStatusEnum.WAIT_CHECK.getValue());
            form.setZpOrder(XeConstans._XE_ONE);
            form.setOrderException(VenOrderExpFlagEnum.NO_PROBLEM.getValue());
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("orderForm", form);
            if (XeConstans._XE_TWO == userInfo.getAdminFlag()) {
                if (StringUtils.isNotBlank(userInfo.getRoleIds())) {
                    paramMap.put("roleId", userInfo.getRoleIds().split(","));
                } else {
                    paramMap.put("roleId", null);
                }
                paramMap.put("admin", "noAdmin");
            } else {
                paramMap.put("admin", null);
            }
            //2.获取数据
            List<XeVenOrderExportDTO> orderExportDTOList = orderCenterExportService.queryExportOrderList(paramMap);
//			if (null == orderExportDTOList || orderExportDTOList.size() == 0)
//				return sendAjaxOK("导出数据为空！");
//			orderExportDTOList.stream().forEachOrdered(orderExportDTO -> {
            int size = orderExportDTOList.size();
            for (int i = 0; i < size; i++) {
                XeVenOrderExportDTO orderExportDTO = orderExportDTOList.get(i);
                if (StringUtils.isNotBlank(orderExportDTO.getCaAreaId())) {
                    String orgAreaName = XeBaseUtil.baseUtil.getOrgAreaName(Integer.parseInt(orderExportDTO.getCaAreaId().trim()));
                    orderExportDTO.setCaArea(orgAreaName);
                } else if (StringUtils.isNotBlank(orderExportDTO.getCaCityId()) && StringUtils.isBlank(orderExportDTO.getCaAreaId())) {
                    String caCityName = XeBaseUtil.baseUtil.getAreaName(Integer.parseInt(orderExportDTO.getCaCityId().trim()));
                    String caProvinceName = XeBaseUtil.baseUtil.getAreaName(Integer.parseInt(orderExportDTO.getCaProvinceId().trim()));
                    orderExportDTO.setCaArea(caCityName + "" + caProvinceName);
                }
                if (StringUtils.isNotEmpty(orderExportDTO.getPayType())) {
                    //应收
                    orderExportDTO.setPayAbleAmount(orderExportDTO.getPayAbleAmount());
                    //实收
                    orderExportDTO.setProPayAmount(orderExportDTO.getPayAbleAmount());
                    if (orderExportDTO.getPayType().equals("货到付款")) {
                        //实收
                        orderExportDTO.setProPayAmount(new BigDecimal("0"));
                    }
                }
                if (StringUtils.isNotBlank(orderExportDTO.getSalesmanName())) {
                    orderExportDTO.setSalesmanName(orderExportDTO.getSalesmanName() + orderExportDTO.getSalesmanPhone());
                }
            }
//			});
            //3.判断导数数据是否需要生成定制任务，限制最多导出50000条数据，大于50000生成定制任务
            Integer pageCount = XeVenExcelUtil.getPageCount(orderExportDTOList.size(), 50000);
            if (pageCount <= 1) {
                //4.导出
                boolean rs = XeVenExcelUtil.exportExcelService(orderExportDTOList, new XeVenOrderExportDTO(), form.getFieldArr(), exportTempletDir, "ORDERLIST-", response);
                if (rs) {
                    return sendAjaxOK();
                } else {
                    return sendAjaxError();
                }
            } else {
                //5.如果导出数据大于50000，生成定制任务，异步进行导出
                XeVenOrderExportTask orderExportDTOTask = new XeVenOrderExportTask();
                orderExportDTOTask.setEtName("com.xebest.job.common.reflect.ExportOrderList");
                orderExportDTOTask.setEtParam(JSONObject.toJSONString(form));
                orderExportDTOTask.setEtStatus(1);
                orderExportDTOTask.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                orderExportDTOTask.setCreateUser(userInfo.getUserName());
                orderExportDTOTask.setUserCode(userInfo.getUserCode());
                exportTaskService.insertExportTask(orderExportDTOTask);
                Map<String, Object> rsMap = Maps.newHashMap();
                rsMap.put("info", "亲,您导出的数据量过大,为了避免对服务器造成过大压力，您的导出请求已经被系统自动订制！\\n请您到(【系统监控】>【导出Excle信息列表】)查看您的导出进度！给您带来不便，请谅解！");
                return sendAjaxOK(rsMap);
            }

        } catch (Exception e) {
            log.error("订单处理列表导出接口异常：{}", e);
            return sendAjaxError();
        }
    }

    /**
     * 订单处理列表导出明细
     *
     * @author 赵盼飞
     */
    @RequestMapping("exportHandleOrderDetail")
    public @ResponseBody
    BaseResponse exportHandleOrderDetail(@ModelAttribute XeVenOrderForm form, HttpServletResponse response) {
        try {
            //测试
            String[] fieldArr = {
                    "orderId", "createDate", "orderStatus", "orderSource", "venName", "loginAccount", "caConsignee", "caPhone", "caStoreName",
                    "caArea", "caStreet", "orderRemark", "shipType", "salesmanName", "custMagName", "storeName", "sendTime",
                    "payNumber", "payType", "payStatus", "payTime", "totalAmount", "proNum", "proName", "proCategoryName",
                    "pricingTypeStr", "proUnit", "specValue", "proPrice", "proCostPrice", "purchaseNum", "normWeight", "realSendNum",
                    "differenceNum", "orderAmount", "freAmount", "pmtAmount", "specialDisamount", "platPmtAmount", "venPmtAmount"
            };
            form.setFieldArr(fieldArr);
            //1、验证参数
            if (form.getFieldArr().length <= 0) {
                return sendAjaxError(BASEMessage.PARAM_ERROR);
            }
            //设置时间
            if (judgeOrderTime(form)) return sendAjaxError(BASEMessage.PARAM_ERROR, XeVenOrderMsg.TIME_MSG);
            setOrderTime(form);
            ErpUserInfo userInfo = SysSetBeanUtils.getErpUserInfo(super.getErpLoginUserInfo());
            form.setUserCode(userInfo.getUserCode());
            form.setOrderStatus(VenOrderStatusEnum.WAIT_CHECK.getValue());
            form.setZpOrder(XeConstans._XE_ONE);
            form.setOrderException(VenOrderExpFlagEnum.NO_PROBLEM.getValue());
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("orderForm", form);
            if (XeConstans._XE_TWO == userInfo.getAdminFlag()) {
                if (StringUtils.isNotBlank(userInfo.getRoleIds())) {
                    paramMap.put("roleId", userInfo.getRoleIds().split(","));
                } else {
                    paramMap.put("roleId", null);
                }
                paramMap.put("admin", "noAdmin");
            } else {
                paramMap.put("admin", null);
            }
            //2.获取数据
            List<XeVenOrderDetailExportDTO> orderDetailList = orderCenterExportService.queryExportOrderDetailList(paramMap);
//			if(null != orderDetailList && orderDetailList.size()>0){
            //3.判断导数数据是否需要生成定制任务，限制最多导出50000条数据，大于50000生成定制任务
            Integer pageCount = XeVenExcelUtil.getPageCount(orderDetailList.size(), 50000);
            if (pageCount <= 1) {
                //4.导出
                boolean rs = XeVenExcelUtil.exportExcelService(orderDetailList, new XeVenOrderDetailExportDTO(), form.getFieldArr(), exportTempletDir, "ORDERDETAILLIST-", response);
                if (rs) {
                    return sendAjaxOK();
                } else {
                    return sendAjaxError();
                }
            } else {
                //5.如果导出数据大于50000，生成定制任务，异步进行导出
                XeVenOrderExportTask orderExportDTOTask = new XeVenOrderExportTask();
                orderExportDTOTask.setEtName("com.xebest.job.common.reflect.ExportOrderDetailList");
                orderExportDTOTask.setEtParam(JSONObject.toJSONString(form));
                orderExportDTOTask.setEtStatus(1);
                orderExportDTOTask.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                orderExportDTOTask.setCreateUser(userInfo.getUserName());
                orderExportDTOTask.setUserCode(userInfo.getUserCode());
                exportTaskService.insertExportTask(orderExportDTOTask);
                Map<String, Object> rsMap = Maps.newHashMap();
                rsMap.put("info", "亲,您导出的数据量过大,为了避免对服务器造成过大压力，您的导出请求已经被系统自动订制！\\n请您到(【系统监控】>【导出Excle信息列表】)查看您的导出进度！给您带来不便，请谅解！");
                return sendAjaxOK(rsMap);
            }
//			}else{
//				return sendAjaxOK("导出数据为空！");
//			}
        } catch (Exception e) {
            log.error("订单处理列表导出明细接口异常：{}", e);
            return sendAjaxError();
        }
    }


    /**
     * 订单汇总采购列表导出
     *
     * @author 赵盼飞
     */
    @RequestMapping("exportSummaryPurOrderList")
    public @ResponseBody
    BaseResponse exportSummaryPurOrderList(@ModelAttribute XeVenOrderForm form, HttpServletResponse response) {

        try {
            String[] str = new String[]{
                    "orderId", "createDate", "orderStatus", "orderSource", "orderSourceType", "venName", "loginAccount", "caConsignee", "caPhone", "caStoreName",
                    "caArea", "caStreet", "orderRemark", "shipType", "promotOrderType", "salesmanName", "custMagName", "purchaseType", "storeName", "sendTime",
                    "payNumber", "payType", "payStatus", "payTime", "totalAmount", "freAmount", "pmtAmount",
                    "payAbleAmount", "proPayAmount", "refundAmount", "platPmtAmount", "cpnsPmtAomount", "specialDisamount"
            };
            form.setFieldArr(str);
            //1、验证参数
            if (form.getFieldArr().length <= 0) {
                return sendAjaxError(BASEMessage.PARAM_ERROR);
            }
            //设置时间
            if (judgeOrderTime(form)) return sendAjaxError(BASEMessage.PARAM_ERROR, XeVenOrderMsg.TIME_MSG);
            setOrderTime(form);
            ErpUserInfo userInfo = SysSetBeanUtils.getErpUserInfo(super.getErpLoginUserInfo());
            form.setUserCode(userInfo.getUserCode());
            //必须查询分拨仓库的订单
            form.setStoreType(VenStoreTypeEnum.ALLOCATE_STORE.getValue());
            form.setZpOrder(XeConstans._XE_ONE);
            form.setOrderException(VenOrderExpFlagEnum.NO_PROBLEM.getValue());
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("orderForm", form);
            if (XeConstans._XE_TWO == userInfo.getAdminFlag()) {
                if (StringUtils.isNotBlank(userInfo.getRoleIds())) {
                    paramMap.put("roleId", userInfo.getRoleIds().split(","));
                } else {
                    paramMap.put("roleId", null);
                }
                paramMap.put("admin", "noAdmin");
            } else {
                paramMap.put("admin", null);
            }
            //2.获取数据
            List<XeVenOrderExportDTO> orderExportDTOList = orderCenterExportService.queryExportOrderList(paramMap);
//			if (null == orderExportDTOList || orderExportDTOList.size() == 0)
//				return sendAjaxOK("导出数据为空！");
//			orderExportDTOList.stream().forEachOrdered(orderExportDTO -> {
            int size = orderExportDTOList.size();
            for (int i = 0; i < size; i++) {
                XeVenOrderExportDTO orderExportDTO = orderExportDTOList.get(i);
                if (StringUtils.isNotBlank(orderExportDTO.getCaAreaId())) {
                    String orgAreaName = XeBaseUtil.baseUtil.getOrgAreaName(Integer.parseInt(orderExportDTO.getCaAreaId().trim()));
                    orderExportDTO.setCaArea(orgAreaName);
                } else if (StringUtils.isNotBlank(orderExportDTO.getCaCityId()) && StringUtils.isBlank(orderExportDTO.getCaAreaId())) {
                    String caCityName = XeBaseUtil.baseUtil.getAreaName(Integer.parseInt(orderExportDTO.getCaCityId().trim()));
                    String caProvinceName = XeBaseUtil.baseUtil.getAreaName(Integer.parseInt(orderExportDTO.getCaProvinceId().trim()));
                    orderExportDTO.setCaArea(caCityName + "" + caProvinceName);
                }
                //应收
                orderExportDTO.setPayAbleAmount(orderExportDTO.getPayAbleAmount());
                //实收
                orderExportDTO.setProPayAmount(orderExportDTO.getPayAbleAmount());
                if (orderExportDTO.getPayType().equals("货到付款")) {
                    //实收
                    orderExportDTO.setProPayAmount(new BigDecimal("0"));
                }
                if (StringUtils.isNotBlank(orderExportDTO.getSalesmanName())) {
                    orderExportDTO.setSalesmanName(orderExportDTO.getSalesmanName() + orderExportDTO.getSalesmanPhone());
                }
            }
//			});
            //3.判断导数数据是否需要生成定制任务，限制最多导出50000条数据，大于50000生成定制任务
            Integer pageCount = XeVenExcelUtil.getPageCount(orderExportDTOList.size(), 50000);
            if (pageCount <= 1) {
                //4.导出
                boolean rs = XeVenExcelUtil.exportExcelService(orderExportDTOList, new XeVenOrderExportDTO(), form.getFieldArr(), exportTempletDir, "ORDERLIST-", response);
                if (rs) {
                    return sendAjaxOK();
                } else {
                    return sendAjaxError();
                }
            } else {
                //5.如果导出数据大于50000，生成定制任务，异步进行导出
                XeVenOrderExportTask orderExportDTOTask = new XeVenOrderExportTask();
                orderExportDTOTask.setEtName("com.xebest.job.common.reflect.ExportOrderList");
                orderExportDTOTask.setEtParam(JSONObject.toJSONString(form));
                orderExportDTOTask.setEtStatus(1);
                orderExportDTOTask.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                orderExportDTOTask.setCreateUser(userInfo.getUserName());
                orderExportDTOTask.setUserCode(userInfo.getUserCode());
                exportTaskService.insertExportTask(orderExportDTOTask);
                Map<String, Object> rsMap = Maps.newHashMap();
                rsMap.put("info", "亲,您导出的数据量过大,为了避免对服务器造成过大压力，您的导出请求已经被系统自动订制！\\n请您到(【系统监控】>【导出Excle信息列表】)查看您的导出进度！给您带来不便，请谅解！");
                return sendAjaxOK(rsMap);
            }
        } catch (Exception e) {
            log.error("订单汇总采购列表导出接口异常：{}", e);
            return sendAjaxError();
        }
    }

    /**
     * 订单汇总采购列表导出明细
     *
     * @author 赵盼飞
     */
    @RequestMapping("exportSummaryPurOrderDetail")
    public @ResponseBody
    BaseResponse exportSummaryPurOrderDetail(@ModelAttribute XeVenOrderForm form, HttpServletResponse response) {
        try {
            //测试
            String[] fieldArr = {
                    "orderId", "createDate", "orderStatus", "orderSource", "venName", "loginAccount", "caConsignee", "caPhone", "caStoreName",
                    "caArea", "caStreet", "orderRemark", "shipType", "salesmanName", "custMagName", "storeName", "sendTime",
                    "payNumber", "payType", "payStatus", "payTime", "totalAmount", "proNum", "proName", "proCategoryName",
                    "pricingTypeStr", "proUnit", "specValue", "proPrice", "proCostPrice", "purchaseNum", "normWeight", "realSendNum",
                    "differenceNum", "orderAmount", "freAmount", "pmtAmount", "specialDisamount", "platPmtAmount", "venPmtAmount"
            };
            form.setFieldArr(fieldArr);
            //1、验证参数
            if (form.getFieldArr().length <= 0) {
                return sendAjaxError(BASEMessage.PARAM_ERROR);
            }
            //设置时间
            if (judgeOrderTime(form)) return sendAjaxError(BASEMessage.PARAM_ERROR, XeVenOrderMsg.TIME_MSG);
            setOrderTime(form);
            ErpUserInfo userInfo = SysSetBeanUtils.getErpUserInfo(super.getErpLoginUserInfo());
            form.setUserCode(userInfo.getUserCode());
            //必须查询分拨仓库的订单
            form.setStoreType(VenStoreTypeEnum.ALLOCATE_STORE.getValue());
            form.setZpOrder(XeConstans._XE_ONE);
            form.setOrderException(VenOrderExpFlagEnum.NO_PROBLEM.getValue());
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("orderForm", form);
            if (XeConstans._XE_TWO == userInfo.getAdminFlag()) {
                if (StringUtils.isNotBlank(userInfo.getRoleIds())) {
                    paramMap.put("roleId", userInfo.getRoleIds().split(","));
                } else {
                    paramMap.put("roleId", null);
                }
                paramMap.put("admin", "noAdmin");
            } else {
                paramMap.put("admin", null);
            }
            //2.获取数据
            List<XeVenOrderDetailExportDTO> orderDetailList = orderCenterExportService.queryExportOrderDetailList(paramMap);
//			if(null != orderDetailList && orderDetailList.size()>0){
            //3.判断导数数据是否需要生成定制任务，限制最多导出50000条数据，大于50000生成定制任务
            Integer pageCount = XeVenExcelUtil.getPageCount(orderDetailList.size(), 50000);
            if (pageCount <= 1) {
                //4.导出
                boolean rs = XeVenExcelUtil.exportExcelService(orderDetailList, new XeVenOrderDetailExportDTO(), form.getFieldArr(), exportTempletDir, "ORDERDETAILLIST-", response);
                if (rs) {
                    return sendAjaxOK();
                } else {
                    return sendAjaxError();
                }
            } else {
                //5.如果导出数据大于50000，生成定制任务，异步进行导出
                XeVenOrderExportTask orderExportDTOTask = new XeVenOrderExportTask();
                orderExportDTOTask.setEtName("com.xebest.job.common.reflect.ExportOrderDetailList");
                orderExportDTOTask.setEtParam(JSONObject.toJSONString(form));
                orderExportDTOTask.setEtStatus(1);
                orderExportDTOTask.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                orderExportDTOTask.setCreateUser(userInfo.getUserName());
                orderExportDTOTask.setUserCode(userInfo.getUserCode());
                exportTaskService.insertExportTask(orderExportDTOTask);
                Map<String, Object> rsMap = Maps.newHashMap();
                rsMap.put("info", "亲,您导出的数据量过大,为了避免对服务器造成过大压力，您的导出请求已经被系统自动订制！\\n请您到(【系统监控】>【导出Excle信息列表】)查看您的导出进度！给您带来不便，请谅解！");
                return sendAjaxOK(rsMap);
            }
//			}else{
//				return sendAjaxOK("导出数据为空！");
//			}
        } catch (Exception e) {
            log.error("订单汇总采购列表导出明细接口异常：{}", e);
            return sendAjaxError();
        }
    }

    /**
     * 订单打印发货导出
     *
     * @author 赵盼飞
     */
    @RequestMapping("exportPrintShipmentOrderList")
    public @ResponseBody
    BaseResponse exportPrintShipmentOrderList(@ModelAttribute XeVenOrderForm form, HttpServletResponse response) {

        try {
            String[] str = new String[]{
                    "orderId", "createDate", "orderStatus", "venName", "printBatch", "orderSource", "orderSourceType", "loginAccount", "caConsignee", "caPhone", "caStoreName",
                    "caArea", "caStreet", "orderRemark", "shipType", "promotOrderType", "salesmanName", "custMagName", "purchaseType", "storeName", "sendTime",
                    "payNumber", "payType", "payStatus", "payTime", "totalAmount", "freAmount", "pmtAmount",
                    "payAbleAmount", "proPayAmount", "refundAmount", "platPmtAmount", "cpnsPmtAomount", "specialDisamount"
            };
            form.setFieldArr(str);
            //1、验证参数
            if (form.getFieldArr().length <= 0) {
                return sendAjaxError(BASEMessage.PARAM_ERROR);
            }
            //设置时间
            if (judgeOrderTime(form)) return sendAjaxError(BASEMessage.PARAM_ERROR, XeVenOrderMsg.TIME_MSG);
            setOrderTime(form);
            if (null == form.getOrderStatus()) {
                form.setOrderStatu(new String[]{"1", "2", "3"});
            }
            ErpUserInfo userInfo = SysSetBeanUtils.getErpUserInfo(super.getErpLoginUserInfo());
            form.setUserCode(userInfo.getUserCode());

            form.setZpOrder(XeConstans._XE_ONE);
            form.setOrderException(VenOrderExpFlagEnum.NO_PROBLEM.getValue());
            form.setAllStoreType("allStoreType");
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("orderForm", form);
            if (XeConstans._XE_TWO == userInfo.getAdminFlag()) {
                if (StringUtils.isNotBlank(userInfo.getRoleIds())) {
                    paramMap.put("roleId", userInfo.getRoleIds().split(","));
                } else {
                    paramMap.put("roleId", null);
                }
                paramMap.put("admin", "noAdmin");
            } else {
                paramMap.put("admin", null);
            }
            //2.获取数据
            List<XeVenOrderExportDTO> orderExportDTOList = orderCenterExportService.queryExportOrderList(paramMap);
//			if (null == orderExportDTOList || orderExportDTOList.size() == 0)
//				return sendAjaxOK("导出数据为空！");
//			orderExportDTOList.stream().forEachOrdered(orderExportDTO -> {
            int size = orderExportDTOList.size();
            for (int i = 0; i < size; i++) {
                XeVenOrderExportDTO orderExportDTO = orderExportDTOList.get(i);
                if (StringUtils.isNotBlank(orderExportDTO.getCaAreaId())) {
                    String orgAreaName = XeBaseUtil.baseUtil.getOrgAreaName(Integer.parseInt(orderExportDTO.getCaAreaId().trim()));
                    orderExportDTO.setCaArea(orgAreaName);
                } else if (StringUtils.isNotBlank(orderExportDTO.getCaCityId()) && StringUtils.isBlank(orderExportDTO.getCaAreaId())) {
                    String caCityName = XeBaseUtil.baseUtil.getAreaName(Integer.parseInt(orderExportDTO.getCaCityId().trim()));
                    String caProvinceName = XeBaseUtil.baseUtil.getAreaName(Integer.parseInt(orderExportDTO.getCaProvinceId().trim()));
                    orderExportDTO.setCaArea(caCityName + "" + caProvinceName);
                }
                if (StringUtils.isNotEmpty(orderExportDTO.getPayType())) {
                    //实收
                    orderExportDTO.setProPayAmount(new BigDecimal("0"));
                    //应收
                    orderExportDTO.setPayAbleAmount(orderExportDTO.getPayAbleAmount());
                    if (orderExportDTO.getConfirmSendNum() == 2) {
                        //应收
                        orderExportDTO.setPayAbleAmount(orderExportDTO.getEpayReceAmt());
                    }
                    if (orderExportDTO.getPayType().equals("货到付款") && orderExportDTO.getOrderStatus().equals("已完成")) {
                        orderExportDTO.setProPayAmount(orderExportDTO.getEpayReceAmt());
                    }
                    if (orderExportDTO.getPayType().equals("在线支付") && orderExportDTO.getPayStatus().equals("已支付")) {
                        orderExportDTO.setProPayAmount(orderExportDTO.getPayAbleAmount());
                    }
                }
                if (StringUtils.isNotBlank(orderExportDTO.getSalesmanName())) {
                    orderExportDTO.setSalesmanName(orderExportDTO.getSalesmanName() + orderExportDTO.getSalesmanPhone());
                }
            }
//			});
            //3.判断导数数据是否需要生成定制任务，限制最多导出50000条数据，大于50000生成定制任务
            Integer pageCount = XeVenExcelUtil.getPageCount(orderExportDTOList.size(), 50000);
            if (pageCount <= 1) {
                //4.导出
                boolean rs = XeVenExcelUtil.exportExcelService(orderExportDTOList, new XeVenOrderExportDTO(), form.getFieldArr(), exportTempletDir, "ORDERLIST-", response);
                if (rs) {
                    return sendAjaxOK();
                } else {
                    return sendAjaxError();
                }
            } else {
                //5.如果导出数据大于50000，生成定制任务，异步进行导出
                XeVenOrderExportTask orderExportDTOTask = new XeVenOrderExportTask();
                orderExportDTOTask.setEtName("com.xebest.job.common.reflect.ExportOrderList");
                orderExportDTOTask.setEtParam(JSONObject.toJSONString(form));
                orderExportDTOTask.setEtStatus(1);
                orderExportDTOTask.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                orderExportDTOTask.setCreateUser(userInfo.getUserName());
                orderExportDTOTask.setUserCode(userInfo.getUserCode());
                exportTaskService.insertExportTask(orderExportDTOTask);
                Map<String, Object> rsMap = Maps.newHashMap();
                rsMap.put("info", "亲,您导出的数据量过大,为了避免对服务器造成过大压力，您的导出请求已经被系统自动订制！\\n请您到(【系统监控】>【导出Excle信息列表】)查看您的导出进度！给您带来不便，请谅解！");
                return sendAjaxOK(rsMap);
            }

        } catch (Exception e) {
            log.error("订单打印发货导出接口异常：{}", e);
            return sendAjaxError();
        }
    }

    /**
     * 订单打印发货导出明细
     *
     * @author 赵盼飞
     */
    @RequestMapping("exportPrintShipmentOrderDetail")
    public @ResponseBody
    BaseResponse exportPrintShipmentOrderDetail(@ModelAttribute XeVenOrderForm form, HttpServletResponse response) {
        try {
            //测试
            String[] fieldArr = {
                    "orderId", "createDate", "orderStatus", "orderSource", "venName", "printBatch", "loginAccount", "caConsignee", "caPhone", "caStoreName",
                    "caArea", "caStreet", "orderRemark", "shipType", "salesmanName", "custMagName", "storeName", "sendTime",
                    "payNumber", "payType", "payStatus", "payTime", "totalAmount", "proNum", "proName", "proCategoryName",
                    "pricingTypeStr", "proUnit", "specValue", "proPrice", "proCostPrice", "purchaseNum", "normWeight", "realSendNum",
                    "differenceNum", "differenceAmountDetail", "realSendAmountDetail", "orderAmount", "freAmount", "pmtAmount", "specialDisamount",
            };
            form.setFieldArr(fieldArr);
            //1、验证参数
            if (form.getFieldArr().length <= 0) {
                return sendAjaxError(BASEMessage.PARAM_ERROR);
            }
            //设置时间
            if (judgeOrderTime(form)) return sendAjaxError(BASEMessage.PARAM_ERROR, XeVenOrderMsg.TIME_MSG);
            setOrderTime(form);
            if (null == form.getOrderStatus()) {
                form.setOrderStatu(new String[]{"1", "2", "3"});
            }
            ErpUserInfo userInfo = SysSetBeanUtils.getErpUserInfo(super.getErpLoginUserInfo());
            form.setUserCode(userInfo.getUserCode());

            form.setZpOrder(XeConstans._XE_ONE);
            form.setOrderException(VenOrderExpFlagEnum.NO_PROBLEM.getValue());
            form.setAllStoreType("allStoreType");
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("orderForm", form);
            if (XeConstans._XE_TWO == userInfo.getAdminFlag()) {
                if (StringUtils.isNotBlank(userInfo.getRoleIds())) {
                    paramMap.put("roleId", userInfo.getRoleIds().split(","));
                } else {
                    paramMap.put("roleId", null);
                }
                paramMap.put("admin", "noAdmin");
            } else {
                paramMap.put("admin", null);
            }
            //2.获取数据
            List<XeVenOrderDetailExportDTO> orderDetailList = orderCenterExportService.queryExportOrderDetailList(paramMap);
//			if(null != orderDetailList && orderDetailList.size()>0){
            //3.判断导数数据是否需要生成定制任务，限制最多导出50000条数据，大于50000生成定制任务
            Integer pageCount = XeVenExcelUtil.getPageCount(orderDetailList.size(), 50000);
            if (pageCount <= 1) {
                //4.导出
                boolean rs = XeVenExcelUtil.exportExcelService(orderDetailList, new XeVenOrderDetailExportDTO(), form.getFieldArr(), exportTempletDir, "ORDERDETAILLIST-", response);
                if (rs) {
                    return sendAjaxOK();
                } else {
                    return sendAjaxError();
                }
            } else {
                //5.如果导出数据大于50000，生成定制任务，异步进行导出
                XeVenOrderExportTask orderExportDTOTask = new XeVenOrderExportTask();
                orderExportDTOTask.setEtName("com.xebest.job.common.reflect.ExportOrderDetailList");
                orderExportDTOTask.setEtParam(JSONObject.toJSONString(form));
                orderExportDTOTask.setEtStatus(1);
                orderExportDTOTask.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                orderExportDTOTask.setCreateUser(userInfo.getUserName());
                orderExportDTOTask.setUserCode(userInfo.getUserCode());
                exportTaskService.insertExportTask(orderExportDTOTask);
                Map<String, Object> rsMap = Maps.newHashMap();
                rsMap.put("info", "亲,您导出的数据量过大,为了避免对服务器造成过大压力，您的导出请求已经被系统自动订制！\\n请您到(【系统监控】>【导出Excle信息列表】)查看您的导出进度！给您带来不便，请谅解！");
                return sendAjaxOK(rsMap);
            }
//			}else{
//				return sendAjaxOK("导出数据为空！");
//			}
        } catch (Exception e) {
            log.error("订单打印发货导出明细接口异常：{}", e);
            return sendAjaxError();
        }
    }


    /**
     * 汇总备货导出
     *
     * @author 赵盼飞
     */
    @RequestMapping("exportStockUp")
    public @ResponseBody
    BaseResponse exportStockUp(@ModelAttribute XeVenOrderForm form, HttpServletResponse response) {
        try {
            //测试
            String[] orderArr = {
                    "orderId", "loginAccount", "caConsignee", "caAddress", "createDate", "orderRemark",
                    "vendorRemark", "payAmount", "differenceAmount", "realSendAmount"};
            String[] orderDetailArr = {
                    "orderId", "proNum", "proName", "proOrgCodeName", "pricingType",
                    "proUnit", "specValue", "purchaseNum", "orderRemark", "caConsignee"};
            String[] productArr = {
                    "orderId", "proNum", "proName", "proOrgCodeName", "pricingType",
                    "proUnit", "specValue", "purchaseNum", "orderRemark", "caConsignee"};
            //设置时间
            if (judgeOrderTime(form)) return sendAjaxError(BASEMessage.PARAM_ERROR, XeVenOrderMsg.TIME_MSG);
            setOrderTime(form);
            form.setStockUpOrderArr(orderArr);
            form.setStockUpOrderDetailArr(orderDetailArr);
            form.setStockUpProductArr(productArr);
            form.setOrderStatus(VenOrderStatusEnum.WAIT_SEND.getValue());
            form.setZpOrder(XeConstans._XE_ONE);
            form.setOrderException(VenOrderExpFlagEnum.NO_PROBLEM.getValue());
            form.setAllStoreType("allStoreType");
            ErpUserInfo userInfo = SysSetBeanUtils.getErpUserInfo(super.getErpLoginUserInfo());
            form.setUserCode(userInfo.getUserCode());
            //权限
            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("orderForm", form);
            if (XeConstans._XE_TWO == userInfo.getAdminFlag()) {
                if (StringUtils.isNotBlank(userInfo.getRoleIds())) {
                    paramMap.put("roleId", userInfo.getRoleIds().split(","));
                } else {
                    paramMap.put("roleId", null);
                }
                paramMap.put("admin", "noAdmin");
            } else {
                paramMap.put("admin", null);
            }

            //1、验证参数
            if (form.getStockUpOrderArr().length <= 0 || form.getStockUpOrderDetailArr().length <= 0 || form.getStockUpProductArr().length <= 0) {
                return sendAjaxError(BASEMessage.PARAM_ERROR);
            }
            log.info("汇总备货入参:{}", JSONObject.toJSONString(form));
            //2.获取数据
            //汇总备货订单维度
            List<XeVenStockUpOrderExDTO> orderList = orderCenterExportService.queryExportStockUpOrderList(paramMap);
            //汇总备货订单明细维度
            List<XeVenStockUpOrderDetailExDTO> orderDetailList = orderCenterExportService.queryExportStockUpOrderDetailList(paramMap);
            //汇总备货商品维度
            List<XeVenStockUpProductExDTO> productList = orderCenterExportService.queryExportStockUpProductList(paramMap);
//			if(null != orderList && orderList.size()>0){
            //3.导出
            List<String> headList1 = null;
            List<String> headList2 = null;
            List<String> headList3 = null;
            headList1 = XeVenExcelUtil.getheadList(new XeVenStockUpOrderExDTO(), form.getStockUpOrderArr());
            headList2 = XeVenExcelUtil.getheadList(new XeVenStockUpOrderDetailExDTO(), form.getStockUpOrderDetailArr());
            headList3 = XeVenExcelUtil.getheadList(new XeVenStockUpProductExDTO(), form.getStockUpProductArr());
            List<Map<String, Object>> paraList = new ArrayList<Map<String, Object>>();
            Map<String, Object> maps1 = new HashMap<String, Object>();
            Map<String, Object> maps2 = new HashMap<String, Object>();
            Map<String, Object> maps3 = new HashMap<String, Object>();
            maps1.put("sheetName", "汇总备货订单维度");
            maps1.put("headList", headList1);
            maps1.put("headField", form.getStockUpOrderArr());
            paraList.add(maps1);
            maps2.put("sheetName", "汇总备货订单明细维度");
            maps2.put("headList", headList2);
            maps2.put("headField", form.getStockUpOrderDetailArr());
            paraList.add(maps2);
            maps3.put("sheetName", "汇总备货商品维度");
            maps3.put("headList", headList3);
            maps3.put("headField", form.getStockUpProductArr());
            paraList.add(maps3);
            String temeName = "templetestockup_" + XeVenExcelUtil.getCurDateStrTemName() + ".xls";
            XeVenExcelUtilMultipleSheet exUtils = new XeVenExcelUtilMultipleSheet(exportTempletDir, exportTempletDir, temeName);
            String temPath = exUtils.createTemplet(paraList);

            //查询出来的数据list
            Map<Integer, Object> dataMap = new HashMap<Integer, Object>();
            dataMap.put(0, orderList);
            dataMap.put(1, orderDetailList);
            dataMap.put(2, productList);
            String exPath = exUtils.generateExcelByTemplate(dataMap, temeName,
                    "templetestockup_" + DateTime.now().toString("yyyyMMdd") + "-"
                            + System.currentTimeMillis() + ".xls", 1);
            //下载生成的文件
            XeVenExcelUtil.download(exportTempletDir + exPath, response);
            //模板使用完成进行删除
            XeVenExcelUtil.deleteFolder(temPath);
            return sendAjaxOK();
//			}else{
//				return sendAjaxOK("导出数据为空！");
//			}
        } catch (Exception e) {
            log.error("订单打印发货导出明细接口异常：{}", e);
            return sendAjaxError();
        }
    }


    /**
     * 导出询价单列表
     *
     * @author 赵盼飞
     */
    @RequestMapping("inquirySheetList")
    public @ResponseBody
    BaseResponse exportInquirySheetList(@ModelAttribute XeVenInquirySheetForm form, HttpServletResponse response) {
        //1、验证参数
        if (form.getFieldArr().length > 0) {
            return sendAjaxError(BASEMessage.PARAM_ERROR);
        }
        //2.获取数据
        List<XeVenInquiryOrderExportDTO> inquiryOrderExportList = orderCenterExportService.queryXeVenInquirySheetExportList(form);
        //3.导出
        boolean rs = XeVenExcelUtil.exportExcelService(inquiryOrderExportList, new XeVenInquiryOrderExportDTO(), form.getFieldArr(), exportTempletDir, "INQUIRYSHEETLIST-", response);
        if (rs) {
            return sendAjaxOK();
        } else {
            return sendAjaxError();
        }

    }


    /**
     * 设置查询时间
     */
    private void setOrderTime(XeVenOrderForm form) {
        if (null != form.getSearchType()) {
            switch (form.getSearchType()) {
                case 1:
                    break;
                case 2:
                    form.setPayNumber(form.getOrderId());
                    form.setOrderId(null);
                    break;
                case 3:
                    form.setProName(form.getOrderId());
                    form.setOrderId(null);
                    break;
                case 4:
                    form.setProNum(form.getOrderId());
                    form.setOrderId(null);
                    break;
                case 5:
                    form.setCaConsignee(form.getOrderId());
                    form.setOrderId(null);
                    break;
                case 6:
                    form.setLoginAccount(form.getOrderId());
                    form.setOrderId(null);
                    break;
                case 7:
                    form.setCheckBatchNum(form.getOrderId());
                    form.setOrderId(null);
                    break;
                case 8:
                    form.setPrintBatchNum(form.getOrderId());
                    form.setOrderId(null);
                    break;
                default:
                    break;
            }
        }
        if (null != form.getSearchTimeType()) {
            switch (form.getSearchTimeType()) {
                case 1:
                    break;
                case 2:
                    form.setStartPayTime(form.getStartCreateDate());
                    form.setEndPayTime(form.getEndCreateDate());
                    form.setStartCreateDate(null);
                    form.setEndCreateDate(null);
                    break;
                case 3:
                    form.setStartSendTime(form.getStartCreateDate());
                    form.setEndSendTime(form.getEndCreateDate());
                    form.setStartCreateDate(null);
                    form.setEndCreateDate(null);
                    break;
                default:
                    break;
            }
        }
    }

    private boolean judgeOrderTime(@RequestBody XeVenOrderForm form) {
        if (StringUtils.isBlank(form.getEndCreateDate()) && StringUtils.isBlank(form.getStartCreateDate())) {
            form.setEndCreateDate(DateUtil.getDate(new Date()));
        }
        if (StringUtils.isBlank(form.getStartCreateDate()) && StringUtils.isNotBlank(form.getEndCreateDate())) {
            String time = DateUtil.strToNMonth(form.getEndCreateDate(), -3);
            form.setStartCreateDate(time);
        }
        if (StringUtils.isBlank(form.getEndCreateDate()) && StringUtils.isNotBlank(form.getStartCreateDate())) {
            String time = DateUtil.strToNMonth(form.getStartCreateDate(), 3);
            form.setEndCreateDate(time);
        }
        if (StringUtils.isNotBlank(form.getStartCreateDate()) && StringUtils.isNotBlank(form.getEndCreateDate())) {
            boolean flag = DateUtil.comparableTime(form.getStartCreateDate(), form.getEndCreateDate());
            if (!flag) {
                return true;
            }
        }
        return false;
    }

}
  
